package com.geecity.flowable.flowabledemo.controller;

import com.geecity.flowable.flowabledemo.entity.R;
import com.geecity.flowable.flowabledemo.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author yuanDing
 * @version 1.0
 * @date 2025-07-24 10:01
 */

@RestController
@RequestMapping("/file")
public class FileController {

    @Autowired
    private FileService fileService;


    @GetMapping("/list")
    public R list(){
        return fileService.list();
    }

    @GetMapping("/info")
    public R info(@RequestParam("folderPath") String folderPath){
        return fileService.info(folderPath);
    }

    @GetMapping("/download")
    public void download(@RequestParam("serverIp") String serverIp, 
                        @RequestParam("filePath") String filePath,
                         @RequestParam(value = "type") String type,
                        HttpServletResponse response) throws IOException {
        fileService.downloadFile(serverIp, filePath, type , response);
    }






}
